#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>

#include <linux/input.h>

#include <linux/platform_device.h>
int report_virtual_event (struct platform_device *pdev) 
{
	return 0;
}

int my_virtual_init(struct platform_device *pdev)
{
	int err = -1;
	struct input_dev *input_dev = NULL;

	input_dev = input_allocate_device();
	if (!input_dev)
	{
		printk("alloc memory failed.!\n");
		goto fail;
	}
	platform_set_drvdata (pdev, input_dev);

	input_dev->name = pdev->name;
	input_dev->phys = "Virtual Event";
	input_dev->dev.parent = &pdev->dev;
	input_dev->id.bustype = BUS_HOST;
	input_dev->id.vendor = 0x0001;
	input_dev->id.product = 0x0001;
	input_dev->id.version = 0x0100;
	printk("register input device failed.!\n");

	err = input_register_device(input_dev);
	if( err )

	{
		printk("register input device failed.!\n");
		goto fail;
	}


	return 0;
fail:
	input_unregister_device(input_dev);
	input_free_device(input_dev);
	return 1;
}

void my_virtual_exit(struct platform_device *pdev)
{
	struct input_dev *input_dev = NULL;
	input_dev = (struct input_dev *)platform_get_drvdata (pdev);
	if ( NULL != input_dev ) {
		input_unregister_device(input_dev);
		input_free_device(input_dev);
	}
}

MODULE_LICENSE("GPL");


